class Solution:
    def isPalindrome(self, s: str) -> bool:
        arr = []
        for c in s:
            if c.isalnum():
                arr.append(c.lower())

        for i in range(len(arr) // 2):
            if arr[i] != arr[-1 - i]:
                return False
        return True

    def isPalindrome2(self, s: str) -> bool:
        left, right = 0, len(s) - 1
        while left < right:
            if not s[left].isalnum():
                left += 1
                continue

            if not s[right].isalnum():
                right -= 1
                continue

            if s[left].lower() != s[right].lower():
                return False

            left += 1
            right -= 1

        return True


print(Solution().isPalindrome2('A man, a plan, a canal: Panama'))
